package com.uniview.util;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class ConvertPwdPropertyConfigurer extends PropertyPlaceholderConfigurer {

	Logger logger = Logger.getLogger(ConvertPwdPropertyConfigurer.class);
	
	@Override
	protected String convertProperty(String propertyName, String propertyValue) {
		if ("ol.password".equals(propertyName)) {
			try {
				return DESUtil.decrypt(propertyValue);
			} catch (Exception e) {
				logger.error("SDMS数据库密码解密异常",e);
			}
		}
		if ("ms.password".equals(propertyName)) {
			try {
				return DESUtil.decrypt(propertyValue);
			} catch (Exception e) {
				logger.error("K3数据库密码解密异常",e);
			}
		}
		if ("epms.password".equals(propertyName)) {
			try {
				return DESUtil.decrypt(propertyValue);
			} catch (Exception e) {
				logger.error("EPMS数据库密码解密异常",e);
			}
		}
		if ("bmp.password".equals(propertyName)) {
			try {
				return DESUtil.decrypt(propertyValue);
			} catch (Exception e) {
				logger.error("BPM数据库密码解密异常",e);
			}
		}
		return propertyValue;
	}
}
